package com.runrunfast.fxj.mapper;

import com.runrunfast.fxj.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.runrunfast.fxj.vo.PageVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @author 陈胤训
 * @since 2019-03-12
 */
@Repository
public interface SysRoleMapper extends BaseMapper<SysRole> {

    List<SysRole> listRolesByUserId(Integer userId);

    @Select("<script> " +
            "select  *  from sys_role" +
            "  <if test='roleName != null'> where description like concat('%',#{roleName},'%') </if>  " +
            " order by sys_role_id  asc  limit #{pageVo.current},#{pageVo.size}" +
            " </script> ")
    List<SysRole> getPageUserList(@Param("pageVo") PageVo pageVo, @Param("roleName") String roleName);
}
